<template>
  <div>
    <el-dialog title="兑换明细" :visible.sync="dialogVisible" width="700px" :close-on-click-modal="false" @close="close">
      <div v-loading="loading" class="content">
        <el-form ref="form" label-width="120px" size="small">
          <el-form-item label="兑换时间：">{{ row.createTime }}</el-form-item>
          <el-form-item label="消耗积分：" class="app-text-color-danger">{{ row.totalPoint }} 积分</el-form-item>
          <el-form-item label="兑换内容：">{{ row.title }}</el-form-item>
          <!-- 类型券 -->
          <el-form-item v-if="data.productType===0" label="兑换所得：">
            <div v-for="(item,index) in data.couponList" :key="index">{{ item.code.replace(/(.{4})/g, "$1 ") }}&nbsp;&nbsp;&nbsp;{{ item.name }}</div>
          </el-form-item>
          <el-form-item label="兑换单号：">{{ row.orderNo }}</el-form-item>
          <el-form-item label="兑换人：">{{ row.customerName }}</el-form-item>
          <el-form-item label="会员卡类型：">{{ row.memberCardName }}</el-form-item>
          <el-form-item label="会员卡号：">{{ row.memberCardNo }}</el-form-item>
        </el-form>
      </div>

      <!-- <div slot="footer" class="dialog-footer">
        <el-button size="small" round @click="hide">取 消</el-button>
        <el-button size="small" round type="primary" @click="handleSubmit()">确 定</el-button>
      </div>-->
    </el-dialog>
  </div>
</template>

<script>
import { getPointsMallRecordsDetail } from '@/api/statement'
export default {
  data() {
    return {
      resolve: null,
      reject: null,
      dialogVisible: null,
      loading: false,
      row: {},
      data: {}
    }
  },
  methods: {
    open(row) {
      this.row = row
      this.initData(row.orderNo)
      this.show()
      return new Promise((resolve, reject) => {
        this.resolve = resolve
        this.reject = reject
      })
    },

    show() {
      this.dialogVisible = true
    },

    close() {},

    hide() {
      this.resolve = null
      this.reject = null
      this.dialogVisible = false
    },

    /**
       * 获取数据
       */
    // 获取详情
    initData(orderNo) {
      this.loading = true
      getPointsMallRecordsDetail({ orderNo })
        .then(res => {
          this.data = res.data
        })
        .finally(() => {
          this.loading = false
        })
    }

    // handleSubmit() {}
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
  .el-form-item {
    margin-bottom: 0;
  }
</style>
